<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: trusted_shop_reviews.php 323 2013-09-26 19:52:24Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 323 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-26 19:52:24 +0000 (Thu, 26 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(TRUSTED_SHOP_STATUS == 'true') {
	$box_smarty = new Smarty();
	$box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');
	
	if (!function_exists('file_put_contents')) {
		function file_put_contents($file, $contents = '', $method = 'w+') {
			if($file_handle = fopen($file, $method)){
				fwrite($file_handle, $contents);
				fclose($file_handle);
				return true;
			}
		}
	}
	
	function imagecheck($filename_cache, $timeout = 10800) {
		if (file_exists($filename_cache)) {
			$timestamp = filemtime($filename_cache);
			if (time() - $timestamp < $timeout)
				return true;
			else
				return false;
		} else
			return false;
	}
	
	$filename = 'cache/'.TRUSTED_SHOP_NR.'.gif';
	
	if (!imagecheck($filename, 10800)) {
		if($current = @file_get_contents('https://www.trustedshops.com/bewertung/widget/widgets/'.TRUSTED_SHOP_NR.'.gif'))
			file_put_contents($filename, $current);
	}
	if(!empty($filename))
		$box_smarty->assign('BOX_CONTENT', '<a target="_blank" href="https://www.trustedshops.de/bewertung/info_'.TRUSTED_SHOP_NR.'.html" title="Kundenbewertungen einsehen"><img '.get_img_size($filename, 183).' class="bewertung" alt="Kundenbewertungen" src="'.$filename.'" /></a>'); 
	$box_smarty->caching = false;
	$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_trusted_shop_reviews.html');
}